﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:RandomFileCopier"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:behaviors="clr-namespace:RandomFileCopier.Behaviors">
    <ControlTemplate x:Key="ErrorTemplateSilverlightStyle">
        <StackPanel Orientation="Horizontal">
            <!-- Defines TextBox outline border and the ToolTipCorner -->
            <Border x:Name="border" BorderThickness="1.25"
                              BorderBrush="#FFDC000C">
                <Grid>
                    <Polygon x:Name="toolTipCorner"
                   Grid.ZIndex="2"
                   Margin="-1"
                   Points="9,9 9,0 0,0"
                   Fill="#FFDC000C"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   IsHitTestVisible="True"/>
                    <Polyline Grid.ZIndex="3"
                    Points="10,10 0,0"
                    Margin="-1"
                    HorizontalAlignment="Right"
                    StrokeThickness="1.5"
                    StrokeEndLineCap="Round"
                    StrokeStartLineCap="Round"
                    Stroke="White"
                    VerticalAlignment="Top"
                    IsHitTestVisible="True"/>
                    <AdornedElementPlaceholder x:Name="adorner"/>
                </Grid>
            </Border>
            <!-- Defines the Popup -->
            <Popup x:Name="placard"
             AllowsTransparency="True"
             PopupAnimation="Fade"
             Placement="Top"
             PlacementTarget="{Binding ElementName=toolTipCorner}"
             PlacementRectangle="10,-1,0,0">
                <!-- Used to reposition Popup when dialog moves or resizes -->
                <i:Interaction.Behaviors>
                    <behaviors:RepositionPopupBehavior/>
                </i:Interaction.Behaviors>
                <Popup.Style>
                    <Style TargetType="{x:Type Popup}">
                        <Style.Triggers>
                            <!-- Shows Popup when TextBox has focus -->
                            <DataTrigger Binding="{Binding ElementName=adorner, Path=AdornedElement.IsFocused}"
                           Value="True">
                                <Setter Property="IsOpen" Value="True"/>
                            </DataTrigger>
                            <!-- Shows Popup when mouse hovers over ToolTipCorner -->
                            <DataTrigger Binding="{Binding ElementName=toolTipCorner, Path=IsMouseOver}"
                           Value="True">
                                <Setter Property="IsOpen" Value="True"/>
                            </DataTrigger>
                            <!-- Hides Popup when window is no longer active -->
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=IsActive}"
                           Value="False">
                                <Setter Property="IsOpen" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Popup.Style>
                <Border x:Name="errorBorder"
                Background="#FFDC000C"
                Margin="0,0,8,8"
                Opacity="1"
                CornerRadius="4"
                IsHitTestVisible="False"
                MinHeight="24"
                MaxWidth="267">
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="4"
                              Color="Black"
                              Opacity="0.6"
                              Direction="315"
                              BlurRadius="4"/>
                    </Border.Effect>
                    <TextBlock Text="{Binding ElementName=adorner, Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent}"
                     Foreground="White"
                     Margin="8,3,8,3"
                     TextWrapping="Wrap"/>
                </Border>
            </Popup>
        </StackPanel>
    </ControlTemplate>
</ResourceDictionary>

